#include <iostream>
#include <vector>
using namespace std;
int ret;
int n,m;
vector<vector<char>> arr;
int dx[4]={0,0,-1,1};
int dy[4]={1,-1,0,0};
void dfs(int x,int y)
{
	ret++;
	arr[x][y]='#';
	for(int i=0;i<4;i++)
	{
		int nx=x+dx[i];
		int ny=y+dy[i];
		if(nx<1 || nx>n || ny<1 || ny>m || arr[nx][ny]=='#')
			continue;
		dfs(nx,ny);
	}
}
int main()
{
	
	while(cin>>m>>n , n || m)
	{
		int sx,sy;
		arr.resize(n+1,vector<char>(m+1));
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=m;j++)
			{
				cin>>arr[i][j];
				if(arr[i][j]=='@')
					sx=i,sy=j;
			}
		}
		ret=0;
		dfs(sx,sy);
		cout<<ret<<endl;
	}
	return 0;
}
